<?
 session_start();
 if (@$_SESSION['panel']==0) { header('Location: login.php');};
 require_once("../core.php");
 
 @get_all_variables();
 $db = dbconnect();

 $q = "SELECT *
       FROM `messages`
       WHERE dest = 0
       ORDER BY `id` ASC";

 $rmsgs = mysql_query($q, $db) or die(mysql_error());
 $nmsgs = mysql_num_rows($rmsgs);
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>openOli Jury | Inbox</title>
<link rel="icon" href="../img/favicon.png" type="image/png" />
<link href="../css/yahoo_reset.css" rel="stylesheet" type="text/css" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link href="css/inbox.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/jquery.js"></script>
<script type="text/javascript">
      $(document).ready(function(){
          setInterval(function(){$("#timebox").load("../time.php");}, 30000);
        })
</script>

</head>

<body>
  <!-- openOli::Contest | Turan Rustamli -->
  <div id="page">


	<div id="header">
	   <div id="logo"><a href="/jury"><img src="img/logo.jpg" alt="openOli" border="0"></a></div>
	   <div id="topmenu">
	        <a class="foxbtn_x" href="inbox.php"><span>Inbox</span></a>
            <a class="foxbtn" href="table.php"><span>Table</span></a>
			<a class="foxbtn" href="logout.php"><span>Log out</span></a>
	   </div>
	   <div id="toolbox">
		  <div id="timebox">
	        <? include ('../time.php'); ?>
		  </div>
		</div>
	</div>

	<div id="content">
	   <table width="100%" border="0" cellspacing="2">
		<tr>
			<td>
            <p class="p_title">Send Announcement</p>
	           <p class="p_text">
                <form action="announ.php" method="post">
                  <textarea class="question" name="announ" id="announ"></textarea>
                  <input type="submit" value="Submit" id="ok_quest" />
                </form>
               </p>
               <br/>
             <p class="p_title">Messages (<a href="inbox.php" style="color: red;">update</a>)</p>
            <? for ($i=0; $i<$nmsgs; $i++) {
                        $msgs = mysql_fetch_array($rmsgs);
                        $q2 = "SELECT * FROM clients WHERE id=".$msgs['source'];
                        $r2 = mysql_query($q2, $db) or die(mysql_error());
                        $w2 = mysql_fetch_array($r2);
            ?>
             <div class="pInfo">
                   <img class="photo" src="img/msg.png" />
                   <p class="fullname"><? echo $w2['title']; ?></p>
                   <p class="university"><? echo $msgs['text']; ?></p>
                   <br/><br/><br/>
                   <b>Reply</b>
               <form action="send.php" method="post">
               <p class="p_text">
                  <textarea class="question" id="question<? echo $msgs['id']; ?>" name="question<? echo $msgs['id']; ?>"></textarea>
                  <input type="submit" value="Submit" id="ok_quest" />
                  <input type="hidden" value="<? echo $msgs['source']; ?>" name="sender" id="sender" />
                  <input type="hidden" value="<? echo $msgs['id']; ?>" name="msgid" id="msgid" />
               </p>
               </form>
			 </div>
            <? }; ?>
              
			<td id="sidebar">
		    <p class="p_title">Information</p>
			<p class="p_text">
			   You are at Contest Administration Inbox page.
			   You can send Announcements to all contestants from Send Announcement Textbox. And you can also answer to queries from each contestant at this page.
			 
			   </p>
			 </td>
		</tr>
       </table>
	</div>

	<div id="bottom"><span id="b_left" style="color:black;">&copy; Turan Rustamli - You may use openOli under the terms of the MIT License.</div></div>
	<br />
  </div>
</body>
</html>